#include <ostream>
#include "CircleLinkList.h"

class Person {
    public:
        CircleLinkNode node;
        string name;
        int age;
        int score;

    Person(string name, int age, int score) : name(name), age(age), score(score) {

    }

        bool operator==(const Person &rhs) const {
        return  name == rhs.name &&
               age == rhs.age &&
               score == rhs.score;
    }

    bool operator!=(const Person &rhs) const {
        return !(rhs == *this);
    }
};

void MyPrint(CircleLinkNode* data) {
    Person* p = (Person*)data;
    cout<<*p<<endl;
}

bool MyCompare(CircleLinkNode* data1,CircleLinkNode* data2) {
    return data1 == data2;
}

int main() {

    //创建循环链表
    CircleLinkList* list = new CircleLinkList();
    list = list->Init_CircleLinkList();

    //创建数据
    Person p1("aaa",11,30);
    Person p2("bbb",12,40);
    Person p3("ccc",13,50);
    Person p4("ddd",14,60);
    Person p5("eee",15,70);

    //数据入链表
    list->Insert_CircleLinkList(100,(CircleLinkNode*)&p1);
    list->Insert_CircleLinkList(100,(CircleLinkNode*)&p2);
    list->Insert_CircleLinkList(100,(CircleLinkNode*)&p3);
    list->Insert_CircleLinkList(100,(CircleLinkNode*)&p4);
    list->Insert_CircleLinkList(100,(CircleLinkNode*)&p5);

    //打印
    list->Print_CircleLinkList(MyPrint);

    cout<<"================================="<<endl;

    Person pDel("ccc",13,50);

    //删除
    list->RemoveByValue_CircleLinkList((CircleLinkNode*)&pDel,MyCompare);

    //打印
    list->Print_CircleLinkList(MyPrint);

    //释放内存
    list->FreeSpace_CircleLinkList();
    return 0;
}